# -*- coding = utf-8 -*-
# @Time : 2021/4/30 20:42
# @Author : 龙王赘婿_彪少
# @File : demo04.py
# @Software: PyCharm

#前面是键，后面是值
info = {"name":"刘志彪","age":"26"}
print(info)
print(info["name"])
print(info["age"])


print(info.get("name"))
print(info.get("gender"))
print(info.get("gender","男")) #没找到就是默认值

#增
newID = 123
info["id"] = newID
info["test"] = 949
info["tst"] = 466
print(info)

#删
# del info["test"]
# print(info)
# info.clear()
# print(info)

#改
print(info)
info["id"] = 222
print(info)

#查
print(info.keys()) #得到列表
print(info.values()) #得到值
print(info.items()) #每个键值对，是一个元组

for key in info.keys():
    print(key)

for values in info.values():
    print(values)

for key,values in info.items():
    print(key,values)

for i,x in enumerate(info):
    print(i,x)  #拿下标，牛逼